//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;
using OpenLS.Drawing.Internals;

namespace OpenLS.Drawing
{
    public class GlowEffect : Effect
    {
        private double? _rad;
        private ColorBase color;

        public ColorBase Color
        {
            get { return color; }
            set { color = value; }
        }


        public double? Radius
        {
            get { return _rad; }
            set { _rad = value; }
        }


        internal override void ReadXmlCore(ReadContext context)
        {
            using (var c = context.Read("glow"))
            {
                Radius = EmuConverter.FromEmu(c.GetOptionalInteger64("rad"));
                c.PassAttributes();
                Color = ColorBase.ReadColor(c);
            }
        }

        internal override void WriteXmlCore(WriteContext context)
        {
            using (WriteContext c = context.Write("glow"))
            {
                c.SetOptionalInteger64("rad", EmuConverter.ToEmu(Radius));
                //\\((PositiveCoordinate) Radius).WriteOptional(c, "rad");
                //\\c.SetOptionalInteger("rad", ((PositiveCoordinate)Radius), 0);
                c.WriteElement(Color);
            }
        }
    }
}